<?php
require_once 'Vega/Module/Action.php';
require_once 'Vega/App/Mobile.php';

class IndexAction extends Vega_Module_Action
{
    public function execute()
    {
		if (Vega_App_Mobile::isMobileDevice()) {
			$this->setOption('layout', 'wap');
			define('WAP_MODE', 1);
		}
		
		$commonDao = Vega_Dao::factory('Bbservice_Common');
		
		//optional params
		$options = '';

		$flags = 0;
		
		//view upcoming for past
		if (isset($_REQUEST['recent'])) {
			$flags = PAST_ONLY;
			$this->_view->assign('recent', 1);
		}
		else 
			$flags = IGNORE_PAST;
		
		$param = Array();
		$param['limit'] = 20;
		
		//filter by user
		$userId = isset($_REQUEST['u'])?$_REQUEST['u']:'';		
		if ($userId) $param['user_id'] = $userId;
		
		$data = $commonDao->getHarvertData($param, $flags);
		
		$users = $commonDao->getUsersList();
		
		if ($options != '') $options = '?'.$options;
		
		$this->_view->assign('data', $data);
		$this->_view->assign('users', $users);
		$this->_view->assign('userId', $userId);
    }
 
}